#include "dkglAxes.h"
#include "dkglPreRequest.h"

namespace DKGL
{
    namespace Primitive
    {
        Axes::Axes():
            Drawable("Axis"),
            _size(1.0f),
	        _length(4.0f),
	        _radius(0.2f)
        {
        }

        Axes::~Axes()
        {
        }

        void Axes::renderImpl()
        {
            GLUquadricObj *quadric = NULL;
	        glPushMatrix();
	
	        glPushAttrib(GL_LIGHTING_BIT | GL_POLYGON_BIT);
	        glDisable(GL_LIGHTING);
	        glPolygonMode( GL_FRONT,GL_FILL);
	
	        quadric = gluNewQuadric();

	        glColor3ub(0xFF, 0x0, 0x0);
	        gluSphere(quadric, _radius*1.3f,8,8);
            /////////////////////////////////////
	        glColor3ub(0x0, 0x0, 0xFF);
	        gluCylinder(quadric,_radius, _radius , _length,8,8);

	        glTranslatef(0.0f, 0.0f, _length);
	        gluCylinder(quadric,_radius*2.0f,_radius*0.01f,_length/3,8,8);
	        glTranslatef(0.0f, 0.0f, -_length);
            /////////////////////////////////////
	        glRotatef(-90.0f, 1.0f, 0.0f, 0.0f);
	        glColor3ub(0x0, 0xFF, 0x0);
	        gluCylinder(quadric,_radius, _radius ,_length,8,8);

	        glTranslatef(0.0f, 0.0f, _length);
	        gluCylinder(quadric,_radius*2.0f,_radius*0.01f,_length/3,8,8);
	        glTranslatef(0.0f, 0.0f, -_length);
            //////////////////////////////////////
	        glRotatef(90.0f, 0.0f, 1.0f, 0.0f);
	        glColor3ub(0xFF, 0x0, 0x0);
	        gluCylinder(quadric,_radius, _radius ,_length,8,8);

	        glTranslatef(0.0f, 0.0f, _length);
	        gluCylinder(quadric,_radius*2.0f,_radius*0.01f,_length/3,8,8);
	        glTranslatef(0.0f, 0.0f, -_length);

	        gluDeleteQuadric(quadric);
	        glPopMatrix();
	        glPopAttrib();
        }//Endof renderImpl
    }
}